package org.dce.screencapturer.actions.objects;

import java.awt.Font;
import java.awt.event.ActionEvent;

import javax.swing.Icon;

import org.dce.screencapturer.objects.ShapeObject;
import org.dce.screencapturer.objects.TextAttributes;

@SuppressWarnings("serial")
public abstract class FontAction 
	extends TextAttributeAction {


	public FontAction(String name, Icon icon) {
		super("categories.text", name, icon);
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		ShapeObject shapeObject = (ShapeObject) getObject();
		
		TextAttributes textAttributes = (TextAttributes)shapeObject.getTextAttributes().clone();
		
		Font font = textAttributes.getFont();
		
		font = modifyFont(font);
		
		textAttributes.setFont(font);
		
		shapeObject.setTextAttributes(textAttributes);
	}
	
	protected abstract Font modifyFont(Font font);

}
